﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Skywave.ComponentModel
{
    [DataContract]
    public class Profile : System.ComponentModel.INotifyPropertyChanged
    {
        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(info));
            }
        }

        private int _Id;
        /// <summary>
        /// ...
        /// </summary>
        [DataMember]
        public int Id
        {
            get { return _Id; }
            set { _Id = value; NotifyPropertyChanged("Id"); }
        }

        private int? _RemoteId;
        /// <summary>
        /// ...
        /// </summary>
        [DataMember]
        public int? RemoteId
        {
            get { return _RemoteId; }
            set { _RemoteId = value; NotifyPropertyChanged("RemoteId"); NotifyPropertyChanged("Type_Text"); }
        }

        /// <summary>
        /// ...
        /// </summary>
        [IgnoreDataMember]
        public string Type_Text
        {
            get { return (RemoteId == null || !IsRemote) ? Properties.Resources.Profile_Local : Properties.Resources.Profile_Remote; }
        }

        private string _Text;
        /// <summary>
        /// ...
        /// </summary>
        [DataMember]
        public string Text
        {
            get { return _Text; }
            set { _Text = value; NotifyPropertyChanged("Text"); }
        }

        private DateTime? _Remote_LastUpdateDateInCache;
        /// <summary>
        /// ...
        /// </summary>
        [DataMember]
        public DateTime? Remote_LastUpdateDateInCache
        {
            get { return _Remote_LastUpdateDateInCache; }
            set { _Remote_LastUpdateDateInCache = value; NotifyPropertyChanged("Remote_LastUpdateDateInCache"); NotifyPropertyChanged("Remote_LastUpdateDateInCache_Text"); }
        }

        /// <summary>
        /// ...
        /// </summary>
        [IgnoreDataMember]
        public string Remote_LastUpdateDateInCache_Text
        {
            get { return (new DateTimeHelper(DateTimeHelperCalendars.Persian, Remote_LastUpdateDateInCache, DateTimeKind.Local)).ToFormatedString(DateTimeHelperDisplayFormats.ShortDate, true); }
        }

        private DateTime _Remote_LastUpdateDate;
        /// <summary>
        /// ...
        /// </summary>
        [DataMember]
        public DateTime Remote_LastUpdateDate
        {
            get { return _Remote_LastUpdateDate; }
            set { _Remote_LastUpdateDate = value; NotifyPropertyChanged("Remote_LastUpdateDate"); NotifyPropertyChanged("Remote_LastUpdateDate_Text"); }
        }

        /// <summary>
        /// ...
        /// </summary>
        [IgnoreDataMember]
        public string Remote_LastUpdateDate_Text
        {
            get { return (new DateTimeHelper(DateTimeHelperCalendars.Persian, Remote_LastUpdateDate, DateTimeKind.Local)).ToFormatedString(DateTimeHelperDisplayFormats.ShortDate, true); }
        }

        private DateTime _LastSaveDate;
        /// <summary>
        /// ...
        /// </summary>
        [DataMember]
        public DateTime LastSaveDate
        {
            get { return _LastSaveDate; }
            set { _LastSaveDate = value; NotifyPropertyChanged("LastSaveDate"); NotifyPropertyChanged("LastSaveDate_Text"); }
        }

        /// <summary>
        /// ...
        /// </summary>
        [IgnoreDataMember]
        public string LastSaveDate_Text
        {
            get { return (new DateTimeHelper(DateTimeHelperCalendars.Persian, LastSaveDate, DateTimeKind.Local)).ToFormatedString(DateTimeHelperDisplayFormats.ShortDate, true); }
        }

        private bool _IsRemote = false;
        /// <summary>
        /// Avialablitiy of Remote functionality for this profile.
        /// (RemoteId maybe not null, but the server didn't provide a profile with that RemoteId)
        /// </summary>
        [IgnoreDataMember]
        public bool IsRemote
        {
            get { return _IsRemote; }
            set { _IsRemote = value; NotifyPropertyChanged("IsRemote"); NotifyPropertyChanged("Type_Text"); }
        }

        public override string ToString()
        {
            return Text;
        }

    }
}
